(function(){
    //var ctx = location.protocol + '://' + location.host + '/';
    $(".btn-submit").on('click', e=>{
        login();
    });
    function login() {
        // $.modal.loading($(".btn-submit").data("loading"));
        var username = $.common.trim($("input[name='username']").val());
        var password = $.common.trim($("input[name='password']").val());
        console.log(ctx);
        //var validateCode = $("input[name='validateCode']").val();
        //var rememberMe = $("input[name='rememberme']").is(':checked');
        $.ajax({
            type: "post",
            url: ctx + "dologin",
            data: {
                "username": username,
                "password": password,
                // "validateCode": validateCode,
                // "rememberMe": rememberMe
            },
            contentType: "application/json",
            success: function(r) {
                if (r.code === 0) {
                    location.href = ctx + 'index';
                } else {
                    $.modal.closeLoading();
                    $('.imgcode').click();
                    $(".code").val("");
                    $.modal.msg(r.msg);
                }
            }
        });
    }
})();